/**
 * 
 */
package edu.wpi.cs509.messages.server;

import edu.wpi.cs509.messages.MsgBc;
import edu.wpi.cs509.network.Connection;
import edu.wpi.cs509.representation.GameID;

/**
 * This class implements the quit-game message.
 * @author sparadis
 *
 */
public class MsgQuitGame extends MsgServerContext{

	/**
	 * serializable version number
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * gId: id of game to quit
	 * conn: this connection
	 */
	protected GameID gId;
	protected Connection conn;
	
	/**
	 * Constructor
	 * @param gId - id of game to quit.
	 */
	public MsgQuitGame(GameID gId) {
		this.gId = gId;
	}

	/**
	 * Quit the game.
	 * @return null - this tells the msg auto-reply code to not send a reply
	 *                msg.
	 */
	@Override
	public MsgBc doExecuteAndGetReply() {
		//Call the server's quit function.
		getServer().leaveGame(gId, getConnection());
		return null;
	}

}
